{% include "base/template_head.html" %}
<link rel="stylesheet" href="/static/css/paging.css">
<script type="text/javascript" src="/static/js/jquery.js"></script>
<script type="text/javascript" src="/static/js/query.js"></script>
<script type="text/javascript" src="/static/js/paging.js"></script>


<div class="row">
    <div class="col-lg-12">
        <div class="row">
            <div class="col-lg-12">
            	<div class="page-header">
                    <h1>发布审核管理</h1>
                </div>
	            <!-- <h2 class="header"><b>发布管理</b></h2> -->
	            <ul class="list-unstyled spaced">
	            	<div class="tabbable">
						<ul class="nav nav-tabs" id="myTab">
							<li class="active">
								<a data-toggle="tab" href="#mypublist" onclick="GetPublishList(1,10)">
									<i class="blue ace-icon fa fa-bullhorn bigger-120"></i>
									我的发布
									<!-- <span class="badge badge-danger" id='mypublistcount'></span> -->
								</a>
							</li>
							<li >
								<a data-toggle="tab" href="#forreview" onclick="GetReviewList(1,10)">
									<i class="orange ace-icon fa fa-check-square-o bigger-120"></i>
									我的审核 &nbsp;
									<!-- <span class="badge badge-danger" id='previewlistcount'></span> -->
								</a>			
							</li>
							<li class="dropdown">
								<a data-toggle="dropdown" class="dropdown-toggle" href="#">
								<i class="purple ace-icon fa fa-th-list bigger-120"></i>
									审核完成 &nbsp;
									<i class="ace-icon fa fa-caret-down bigger-110 width-auto"></i>
								</a>

								<ul class="dropdown-menu dropdown-info dropdown-100">
									<li>
										<a data-toggle="tab" href="#dropdown1" onclick="GetAcceptReviewList(0,1,10)"><i class="green ace-icon fa fa-check bigger-120"></i>&nbsp;&nbsp;审核已通过&nbsp;</a>
									</li>

									<li>
										<a data-toggle="tab" href="#dropdown2" onclick="GetAcceptReviewList(1,1,10)"><i class="red ace-icon fa fa-close bigger-120"></i>&nbsp;&nbsp;审核不通过&nbsp;</a>
									</li>
								</ul>
							</li>
						</ul>

						<div class="tab-content">

							<div id="mypublist" class="tab-pane fade in active">
								<!-- <span style="float: left;color: blue"><b><i class="ace-icon fa fa-bolt"></i>&nbsp;列出所有由我发起的发布申请</b></span> -->
								<span style="float: left;color: blue"><b>&nbsp;总记录数&nbsp;<span id='mypublistcount'></span>&nbsp;条</b></span>
								<div id="SearchBar">
								<div class="nav-search" style="float: right;">
									<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
									<i class="ace-icon fa fa-search nav-search-icon"></i>
									</span>
								</div>									

								</div>

								<br>
								<hr>
								<div class="widget-body">
			                        <div class="widget-main no-padding">
			                            <table class="table table-bordered table-striped">
			                                <thead class="thin-border-bottom">
			                                    <tr>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布ID</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>部署类型</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布者</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>模块名</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>压缩文件包</th>
			                                        <!-- <th><i class="ace-icon fa fa-caret-right blue"></i>发布状态</th> -->
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发起时间</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布主机</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布说明</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>审核者</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>审核状态</th>
			                                    </tr>
			                                </thead>

			                                <tbody id= 'publishlist'>
			                                </tbody>
			                            </table>

			                        </div>
			                    </div>
			                    <br>
								<hr>			                    
			                    <!-- <div id="pageToolbar"></div> -->
							</div>

							<div id="forreview" class="tab-pane fade">
								<!-- <span style="float: left;color: orange"><b><i class="ace-icon fa fa-bolt"></i>&nbsp;列出所有归属于我来进行审核的发布请求</b></span> -->
								<span style="float: left;color: orange"><b>&nbsp;总记录数&nbsp;<span id='previewlistcount'></span>&nbsp;条</b></span>
								<div class="nav-search" style="float: right;">
									<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
									<i class="ace-icon fa fa-search nav-search-icon"></i>
									</span>
								</div>
								<br>
								<hr>
								<div class="widget-body">
			                        <div class="widget-main no-padding">
			                            <table class="table table-bordered table-striped">
			                                <thead class="thin-border-bottom">
			                                    <tr>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布ID</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>部署类型</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布者</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>模块名</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>压缩文件包</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布状态</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发起时间</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布主机</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布说明</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>审核</th>
			                                    </tr>
			                                </thead>

			                                <tbody id= 'previewlist'>
			                                </tbody>
			                            </table>

			                        </div>
			                    </div>
			                    <br>
								<hr>			                    
			                    <!-- <div id="pageToolbar"></div> -->
							</div>

							<div id="dropdown1" class="tab-pane fade">
								<!-- <span style="float: left;color: green"><b><i class="ace-icon fa fa-bolt"></i>&nbsp;列出所有经我来审核通过的发布请求</b></span> -->
								<span style="float: left;color: green"><b>&nbsp;总记录数&nbsp;<span id='reviewacceptcount'></span>&nbsp;条</b></span>
								<div class="nav-search" style="float: right;">
									<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
									<i class="ace-icon fa fa-search nav-search-icon"></i>
									</span>
								</div>
								<br>
								<hr>
								<div class="widget-body">
			                        <div class="widget-main no-padding">
			                            <table class="table table-bordered table-striped">
			                                <thead class="thin-border-bottom">
			                                    <tr>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布ID</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>部署类型</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布者</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>模块名</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>压缩文件包</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布状态</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发起时间</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布主机</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>审核者</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>审核/发布时间</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>审核意见</th>
			                                    </tr>
			                                </thead>

			                                <tbody id= 'reviewed_0'>
			                                </tbody>
			                            </table>

			                        </div>
			                    </div>
			                    <br>
								<hr>			                    
			                    <!-- <div id="pageToolbar"></div> -->
							</div>

							<div id="dropdown2" class="tab-pane fade">
								<!-- <span style="float: left;color: red"><b><i class="ace-icon fa fa-bolt"></i>&nbsp;列出所有经我来审核不通过的发布请求</b></span> -->
								<span style="float: left;color: red"><b>&nbsp;总记录数&nbsp;<span id='reviewrejectcount'></span>&nbsp;条</b></span>
								<div class="nav-search" style="float: right;">
									<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
									<i class="ace-icon fa fa-search nav-search-icon"></i>
									</span>
								</div>
								<br>
								<hr>
								<div class="widget-body">
			                        <div class="widget-main no-padding">
			                            <table class="table table-bordered table-striped">
			                                <thead class="thin-border-bottom">
			                                    <tr>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布ID</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>部署类型</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布者</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>模块名</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>压缩文件包</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布状态</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发起时间</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>发布主机</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>审核者</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>审核/发布时间</th>
			                                        <th><i class="ace-icon fa fa-caret-right blue"></i>审核意见</th>
			                                    </tr>
			                                </thead>

			                                <tbody id= 'reviewed_1'>
			                                </tbody>
			                            </table>

			                        </div>
			                    </div>
								<br>
								<hr>			                    
			                    <!-- <div id="pageToolbar"></div> -->
							</div>

							<div id="pageToolbar"></div>
						</div>

					</div>



				</ul>
            </div>
        </div>
    </div>
    <div class="col-lg-7 col-lg-offset-1">

        <div class="row">
            <div class="col-lg-12">
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
            </div>
        </div>
    </div>





</div>
{% include "base/template_footer.html" %}
<script>



	$(document).ready(function(){
		GetPublishList(1,10);
		$("#nav-search-input").keydown(function(e) {  
          if (e.keyCode == 13) {
          	if($("#nav-search-input").val() != "")
                layer.alert($("#nav-search-input").val())

          }
      });
	});

	function GetPublishList(s_page,page_size) {
		//取出单页数据
		function GetPublishListInfo(s_page,page_size){
			$.ajax({
				type:'POST',
				url:'/review/GetPublishlist/',
				data:{'s_page':s_page,'page_size':page_size},
				dataType:'json',
				success:function(val){
					console.log(val)
					console.log(val.page_total)
					var detail = val.review_data
					// $("#mypublistcount").html(val.page_total)
					if(detail.length==0){
						$("#publishlist").html('<tr><td colspan="9" style="text-align:center;">当前无记录</td></tr>')
					}else{
						$("#publishlist").html("")
					}
					// $('#mypublistcount').html(detail.length)

					for (var i=0;i < detail.length;i++){
						// $("#per_publish_user").html(val.review_data[i].publish_user)
						// console.log(val.review_data[i].publish_user)
						var publish_id = detail[i]['id']
					
					$("#publishlist").append("<tr>\
							<td id='publish_"+(publish_id)+"_id'></td>\
							<td id='publish_"+(publish_id)+"_type'></td>\
							<td id='publish_"+(publish_id)+"_user'></td>\
							<td id='publish_"+(publish_id)+"_module'></td>\
							<td id='publish_"+(publish_id)+"_filename'></td>\
							<td id='publish_"+(publish_id)+"_createtime'></td>\
							<td id='publish_"+(publish_id)+"_serverlist'></td>\
							<td id='publish_"+(publish_id)+"_detail'></td>\
							<td id='publish_"+(publish_id)+"_owner'></td>\
							<td id='publish_"+(publish_id)+"_status'></td></tr>")

					//加载数据

					$("#publish_"+(publish_id)+"_id").html('<a href="/review/review_handle/'+(publish_id)+'/"><span class="badge">'+publish_id+'</span></a>')
					$("#publish_"+(publish_id)+"_type").html(detail[i].publish_type)
					$("#publish_"+(publish_id)+"_user").html(detail[i].publish_user)
					$("#publish_"+(publish_id)+"_module").html(detail[i].publish_module)
					$("#publish_"+(publish_id)+"_filename").html(detail[i].publish_filename)
					$("#publish_"+(publish_id)+"_createtime").html(detail[i].create_time)
					$("#publish_"+(publish_id)+"_serverlist").html(detail[i].publish_serverlist)
					$("#publish_"+(publish_id)+"_detail").html(detail[i].publish_detail.substring(0,20)+"..."+"<a href='/review/review_handle/"+(publish_id)+"/'><span class='badge badge-info'>查看详情</span></a>")
					$("#publish_"+(publish_id)+"_owner").html(detail[i].review_owner)
					$("#publish_"+(publish_id)+"_status").html('<span class="badge badge-warning">'+detail[i].publish_status+'</span>')
					}

					// $('#pageToolbar').html("");
					// $('#pageToolbar').Paging({pagesize:10,count:detail.length});
					

					

				},error:function(){
					console.log('error')
				}
			})			
		};

		//取出总页数
		$.ajax({
			type:'POST',
			url:'/review/GetPublishlistPageCount/',
			dataType:'text',
			success:function(val){
				$('#mypublistcount').html(val)
				// console.log(val)
				GetPublishListInfo(s_page,page_size);

				//加载页码
				$('#pageToolbar').html("");
				$('#pageToolbar').Paging({pagesize:10,count:val,callback:function(page,size,count){
					//page:当前选择页码
					//size:当前每页显示数量
					//count：当前页码总数(含有多少个size)
					GetPublishListInfo(page,10)
					}
				});
			},error:function(){
				console.log('error')
			}
		});	


	}

	function GetReviewList(s_page,page_size) {
		//取出单页数据
		function GetReviewListInfo(s_page,page_size){
			$.ajax({
				type:'POST',
				url:'/review/PreViewList/',
				data:{'s_page':s_page,'page_size':page_size},
				dataType:'json',
				success:function(val){
					// console.log(val)
					var detail = val.review_data
					// $("#previewlist").html("")
					// $('#previewlistcount').html(detail.length)
					if(detail.length==0){
						$("#previewlist").html('<tr><td colspan="9" style="text-align:center;">当前无记录</td></tr>')
					}else{
						$("#previewlist").html("")
					}
					for (var i=0;i < detail.length;i++){
						// $("#per_publish_user").html(val.review_data[i].publish_user)
						// console.log(val.review_data[i].publish_user)
						var review_id = detail[i]['id']
					
					$("#previewlist").append("<tr>\
							<td id='review_"+(review_id)+"_id'></td>\
							<td id='review_"+(review_id)+"_type'></td>\
							<td id='review_"+(review_id)+"_user'></td>\
							<td id='review_"+(review_id)+"_module'></td>\
							<td id='review_"+(review_id)+"_filename'></td>\
							<td id='review_"+(review_id)+"_status'></td>\
							<td id='review_"+(review_id)+"_createtime'></td>\
							<td id='review_"+(review_id)+"_serverlist'></td>\
							<td id='review_"+(review_id)+"_detail'></td>\
							<td id='review_"+(review_id)+"_action'></td></tr>")

					//加载数据

					$("#review_"+(review_id)+"_id").html('<a href="/review/review_handle/'+(review_id)+'/"><span class="badge">'+review_id+'</span></a>')
					$("#review_"+(review_id)+"_type").html(detail[i].publish_type)
					$("#review_"+(review_id)+"_user").html(detail[i].publish_user)
					$("#review_"+(review_id)+"_module").html(detail[i].publish_module)
					$("#review_"+(review_id)+"_filename").html(detail[i].publish_filename)
					$("#review_"+(review_id)+"_status").html('<span class="badge badge-warning">'+detail[i].publish_status+'</span>')
					$("#review_"+(review_id)+"_createtime").html(detail[i].create_time)
					$("#review_"+(review_id)+"_serverlist").html(detail[i].publish_serverlist)
					$("#review_"+(review_id)+"_detail").html(detail[i].publish_detail.substring(0,20)+"..."+"<a href='/review/review_handle/"+(review_id)+"/'><span class='badge badge-info'>查看详情</span></a>")
					$("#review_"+(review_id)+"_action").html('<a href="/review/review_handle/'+(review_id)+'/"><div class="btn btn-primary btn-mini">审核</div></a>')
					}
					// $('#pageToolbar').html("");
					// $('#pageToolbar').Paging({pagesize:10,count:detail.length,callback:function(page,size,count){alert('1')}});

				},error:function(){
					console.log('error')
				}
			})			
		};

		//取出总页数
		$.ajax({
			type:'POST',
			url:'/review/PreViewListPageCount/',
			dataType:'text',
			success:function(val){
				$("#previewlistcount").html(val);
				GetReviewListInfo(s_page,page_size);
				//加载页码
				$('#pageToolbar').html("");
				$('#pageToolbar').Paging({pagesize:10,count:val,callback:function(page,size,count){
					//page:当前选择页码
					//size:当前每页显示数量
					//count：当前页码总数(含有多少个size)
					GetReviewListInfo(page,10)
					}
				});
			},error:function(){
				console.log('error')
			}
		});		


	};

	function GetAcceptReviewList(args,s_page,page_size){
		//取出单页数据
		function NewGetAcceptReviewInfo(args,s_page,page_size){
			$.ajax({
				type:'POST',
				url:'/review/ReviewActionList/',
				data:{'args':args,'s_page':s_page,'page_size':page_size},
				dataType:'json',
				success:function(val){
					console.log(val)
					// console.log(args)
					var detail = val.review_data
					// $('#reviewaccept').html(detail.length)
					if(detail.length==0){
						$("#reviewed_"+(args)).html('<tr><td colspan="10" style="text-align:center;">当前无记录</td></tr>')
					}else{
						$("#reviewed_"+(args)).html("")
					}
					// $("#reviewed_"+(args)).html("")
					for (var i=0;i < detail.length;i++){
						// $("#per_publish_user").html(val.review_data[i].publish_user)
						// console.log(val.review_data[i].publish_user)
						var publish_id = detail[i]['publish_id']

							$("#reviewed_"+(args)).append("<tr>\
							<td id='reviewed_"+(args)+(publish_id)+"_id'></td>\
							<td id='reviewed_"+(args)+(publish_id)+"_type'></td>\
							<td id='reviewed_"+(args)+(publish_id)+"_user'></td>\
							<td id='reviewed_"+(args)+(publish_id)+"_module'></td>\
							<td id='reviewed_"+(args)+(publish_id)+"_filename'></td>\
							<td id='reviewed_"+(args)+(publish_id)+"_status'></td>\
							<td id='reviewed_"+(args)+(publish_id)+"_createtime'></td>\
							<td id='reviewed_"+(args)+(publish_id)+"_serverlist'></td>\
							<td id='reviewed_"+(args)+(publish_id)+"_review_owner'></td>\
							<td id='reviewed_"+(args)+(publish_id)+"_review_time'></td>\
							<td id='reviewed_"+(args)+(publish_id)+"_review_info'></td></tr>")

							//加载数据

							$("#reviewed_"+(args)+(publish_id)+"_id").html('<a href="/review/publish_report/'+(publish_id)+'/"><span class="badge">'+publish_id+'</span></a>')
							$("#reviewed_"+(args)+(publish_id)+"_type").html(detail[i].publish_type)
							$("#reviewed_"+(args)+(publish_id)+"_user").html(detail[i].publish_user)
							$("#reviewed_"+(args)+(publish_id)+"_module").html(detail[i].publish_module)
							$("#reviewed_"+(args)+(publish_id)+"_filename").html(detail[i].publish_filename)
							if(args == 0){
								$("#reviewed_"+(args)+(publish_id)+"_status").html('<span class="badge badge-success">'+detail[i].publish_status+'</span>')
							}else{
								$("#reviewed_"+(args)+(publish_id)+"_status").html('<span class="badge badge-danger">'+detail[i].publish_status+'</span>')
							}
							
							$("#reviewed_"+(args)+(publish_id)+"_createtime").html(detail[i].create_time)
							$("#reviewed_"+(args)+(publish_id)+"_serverlist").html(detail[i].publish_serverlist)
							$("#reviewed_"+(args)+(publish_id)+"_review_owner").html(detail[i].review_owner)
							$("#reviewed_"+(args)+(publish_id)+"_review_time").html(detail[i].review_time)
							$("#reviewed_"+(args)+(publish_id)+"_review_info").html(detail[i].review_info.substring(0,10)+"..."+"<a href='/review/publish_report/"+(publish_id)+"/'><span class='badge badge-info'>查看详情</span></a>")
					
					}
					console.log(detail.length)
					return detail.length;
					// console.log(detail.length)

					// $('#pageToolbar').html("");
					// $('#pageToolbar').Paging({pagesize:10,count:val.page_total,callback:function(page,size,count){
					// 	//page:当前选择页码
					// 	//size:当前每页显示数量
					// 	//count：当前页码总数(含有多少个size)
					// 	console.log('当前页是第'+page+'页')
					// 	}
					// });
				},error:function(){
					console.log('error')
				}
			});
		};


		//取出总页数
		$.ajax({
			type:'POST',
			url:'/review/ReviewActionListPageCount/',
			data:{'args':args},
			dataType:'text',
			success:function(val){
				// args:
                // 1-success
                // 2-failed
                if(args == '0'){
                    $("#reviewacceptcount").html(val)
                }else{
                    $("#reviewrejectcount").html(val)
                }
				NewGetAcceptReviewInfo(args,s_page,page_size);
				//加载页码
				$('#pageToolbar').html("");
				$('#pageToolbar').Paging({pagesize:10,count:val,callback:function(page,size,count){
					//page:当前选择页码
					//size:当前每页显示数量
					//count：当前页码总数(含有多少个size)
					NewGetAcceptReviewInfo(args,page,10)
					}
				});
			},error:function(){
				console.log('error')
			}
		});




	};



	
</script>

<!-- 	</body>
</html> -->